home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / terms / kermit / b / ckoexp.doc < prev    next >
Encoding:
Text File  |  1993-07-06  |  7.1 KB  |  202 lines

  1. File CKOEXP.DOC  --  C-KERMIT OS/2 EXTERNAL PROTOCOLS DOCUMENTATION
  2.  
  3. Most recent update: Mon Jul  5 16:49:52 1993
  4.  
  5. This file contains hints and tips about using C-Kermit with external
  6. protocols and using C-Kermit itself as an external protocol.
  7.  
  8.  
  9. INVOKING EXTERNAL PROTOCOLS FROM C-KERMIT
  10.  
  11. Example 1: ZMODEM
  12.  
  13. Assuming you have the m2zmodem program, add these commands to CKERMOD.INI:
  14.  
  15.   define sz !m2zmodem -f 1 -s \%1  ; Send file
  16.   define rz !m2zmodem -f 1 -r \%1  ; Receive file
  17.  
  18. or:
  19.  
  20.   define sz !m2zmodem -u \v(ttyfd) -h -prty 0 -s \%1          ; Send file
  21.   define rz !m2zmodem -u \v(ttyfd) -h -prty 0 -t -res -r \%1  ; Receive file
  22.  
  23. and then use them just as if these were C-Kermit commands, e.g.:
  24.  
  25.   C-Kermit>sz oofa.txt  ; Send OOFA.TXT with ZMODEM protocol
  26.  
  27.  
  28. INVOKING C-KERMIT FROM ANOTHER PROGRAM
  29.  
  30. If you are writing a communications program and wish to incorporate the Kermit
  31. protocol within it, one way is to use the OS/2 function call DosExecPgm to
  32. call up C-Kermit.  You would supply the instructions for Kermit using
  33. command-line options, and Kermit would do the transfer, returning back to your
  34. program when it had finished.
  35.  
  36. The only problem is you might already have opened up the COM port within your
  37. program, so that when Kermit tries to do the same it gets an error code back
  38. from DosOpen.  The -l command line option gets round this problem by letting
  39. C-Kermit inherit the port's open file handle.  -l takes one numeric parameter
  40. which is the handle of the COM port, and it must occur in front of any other
  41. command-line parameter which accesses the COM port.  The following is a
  42. complete C program written using the Microsoft C compiler version 5.1 and the
  43. Microsoft OS/2 Software Development Toolkit, which illustrates how to use the
  44. -l command-line option.
  45.  
  46. #define    INCL_BASE
  47. #include <os2.h>
  48. /*
  49.  *    Example of how to use the C-Kermit -l option to invoke
  50.  *    Kermit from another program under OS/2.
  51.  */
  52. main(int argc, char *argv[]) {
  53. HFILE    ttyfd;
  54. USHORT    action;
  55. int    err,i;
  56. char    failname[80];
  57. char    args[80];
  58. RESULTCODES    res;
  59. struct dcb {            /* Device control block */
  60.     USHORT write_timeout;
  61.     USHORT read_timeout;
  62.     BYTE flags1, flags2, flags3;
  63.     BYTE error_replacement;
  64.     BYTE break_replacement;
  65.     BYTE xon_char;
  66.     BYTE xoff_char;
  67. } ttydcb;
  68.  
  69.     /*** Open a file ***/
  70.     if (err=DosOpen(argv[1],&ttyfd,&action,0L,0,1,0x0012,0L)) {
  71.         printf("Error %d opening %s\n",err,argv[1]);
  72.         exit(1);
  73.     }
  74.     if (err=DosDevIOCtl(&ttydcb,NULL,0x0073,1,ttyfd)) {
  75.         printf("Error %d from IOCTL on %s\n",err,argv[1]);
  76.             exit(1);
  77.     }
  78.     ttydcb.flags3 &= 0xF9;
  79.     ttydcb.flags3 |= 0x04;    /* Read "some" data from line */
  80.     DosDevIOCtl(NULL,&ttydcb,0x0053,1,ttyfd);
  81.  
  82.     /*** Call kermit ***/
  83.     strcpy(args,"ckermit");
  84.     i = strlen(args);
  85.     args[i++]=0;
  86.     sprintf(&args[i],"-l %d -q -s test.c",ttyfd);
  87.     i += strlen(&args[i]);
  88.     args[i++]=0;
  89.     args[i++]=0;
  90.     if (err=DosExecPgm(failname,80,EXEC_SYNC,args,NULL,&res,
  91.                             "CKERMIT.EXE")) {
  92.         printf("Error %d executing Kermit\n",err);
  93.         exit(1);
  94.     }
  95.     
  96.     /*** Print out return code ***/
  97.     printf("Termination code %d\n",res.codeTerminate);
  98.     printf("Result code %d\n",res.codeResult);
  99.  
  100.     /*** Close the file ***/
  101.     if (err=DosClose(ttyfd)) {
  102.         printf("Error %d closing %s\n",err,argv[1]);
  103.     }
  104. }
  105.  
  106.  
  107. USING OS/2 C-KERMIT WITH TE/2
  108. -----------------------------
  109.  
  110. by Brady Flowers, Oberon Software, BBS: 507-388-1154, Fido: 1:292/60
  111.  
  112.  
  113. (Note: This document contains only a brief discussion on using CKERMIT with
  114. TE/2.  You will also need to know how to use CKERMIT, a discussion of which is
  115. beyond the scope of this document; see the documentation accompanying
  116. CKERMIT.  This document may contain errors, use at your own risk.  This
  117. document in no way implies a commitment on the part of Oberon Software or the
  118. author.)
  119.  
  120. 1. You must use CKERMIT Version 5A(188) or later.  This file is available
  121.    on the Oberon BBS as CK5A188.ZIP.
  122.  
  123. 2. It is recommended that you use the SIO comm port driver instead of the
  124.    default COM.SYS.  SIO050.ZIP is also available on the Oberon BBS.  See
  125.    the SIO documentation for information on installing SIO.
  126.  
  127. 3. CKERMIT comes in both 16-bit and 32-bit OS/2 executable formats.  Only
  128.    the 32-bit version is tested.  See the CKERMIT documentation for
  129.    information on installing CKERMIT.
  130.  
  131. 4. Once CKERMIT is installed on your system, you need to set up TE/2 to
  132.    use it as an external program.  You do this by modifying the TE2.XEX
  133.    file.  See the TE/2 documentation for a more detailed discussion on how
  134.    to use the TE2.XEX file.  For our purposes here, we assume that you
  135.    have already installed CKERMIT to your liking in the directory "D:\PBIN",
  136.    and that you have renamed CKOKER32.EXE to CKERMIT.EXE.  In the examples
  137.    below, remember to change the path and file name to match your setup!
  138.  
  139.    Use any text editor to edit the TE2.XEX file. Each entry in the file is
  140.    four lines long; pick any two, four-line entries that you do not use
  141.    and replace them with with the example settings below.  If TE/2 is
  142.    currently running, you will want to exit and restart TE/2 so that it will
  143.    re-read the modified file.
  144.  
  145. A. KERMIT Receive
  146.  
  147.    The four line TE2.XEX file entry should look like:
  148.  
  149.        0x0011,3
  150.        KERMIT Download
  151.        d:\pbin\ckermit.exe
  152.        -l %h -r
  153.  
  154.    - The first line specifies that the program will be run as a child
  155.      program to TE/2, TE/2 will save and restore the screen before and
  156.      after executing the program and wait for a keystroke before returning.
  157.    - The second line is the title that will appear in the "External
  158.      Programs" menu.
  159.    - The third line is the full path/name of the executable (modify this
  160.      to match your setup).
  161.    - The fourth line is the command line parameters for the program, the
  162.      "%h" causes the numeric value of the open Com port handle to be
  163.      passed CKERMIT.
  164.  
  165.    To use KERMIT download, initiate the file transfer with the host
  166.    system and, when the host prompts you to begin receiving, press
  167.    Alt-J and select "KERMIT Download" from the menu.
  168.  
  169.  
  170. B. KERMIT Send
  171.  
  172.    The four-line TE2.XEX file entry should look like:
  173.  
  174.        0x0011,3
  175.        KERMIT Upload
  176.        d:\pbin\ckermit.exe
  177.        -l %h -s %?[Send files(s):]
  178.  
  179.    - The first line specifies that the program will be run as a child
  180.      program to TE/2, TE/2 will save and restore the screen before and
  181.      after executing the program and wait for a keystroke before returning.
  182.  
  183.    - The second line is the title that will appear in the "External
  184.      Programs" menu.
  185.  
  186.    - The third line is the full path/name of the executable (modify this
  187.      to match your setup).
  188.  
  189.    - The fourth line is the command line parameters for the program, the
  190.      "%h" causes the numeric value of the open Com port handle to be
  191.      passed CKERMIT. The "%?[Send files(s):]" will cause TE/2 to present
  192.      you with an input field before executing the program, the prompt for
  193.      the input will be "Send file(s):" and whatever you type here
  194.      (presumably a list of file names) will be placed into the command
  195.      line at this point.
  196.  
  197. To use KERMIT upload, initiate the file transfer with the host system and,
  198. when the host prompts you to begin sending, press Alt-J and select "KERMIT
  199. Upload" from the menu.
  200.  
  201. (End of CKOEXP.DOC - Further contributions welcome)
  202.